#include <iostream>
#include <ctime>
#include "ThreadPool.hpp"
#include "Task.hpp"

int main()
{
    ThtreadPool<Task> *tp = new ThtreadPool<Task>(5);
    tp->Start();
    srand(time(nullptr)^getpid());
    while(true)
    {
        // 1. 构建任务
        int x = rand() % 9 + 1;
        usleep(10);
        int y = rand() % 5;
        char op = opers[rand() % opers.size()];

        Task t(x,y,op);
        tp->Push(t);

        // 2. 交给线程池处理
        std::cout << "main thread is running... " << t.GetTask() << '\n';

        sleep(1);
    }

    return 0;
}